package org.fordprefect.struts2lightboxplugin.views.jsp.ui;

import com.opensymphony.xwork2.util.ValueStack;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ui.TextFieldTag;
import org.apache.struts2.views.jsp.ui.AbstractRemoteCallUITag;
import org.apache.struts2.views.jsp.ui.AbstractUITag;
import org.apache.log4j.Logger;
import org.fordprefect.struts2lightboxplugin.components.LightBox;

/**
 * @see org.fordprefect.struts2lightboxplugin.components.LightBox
 */
public class LightBoxTag extends AbstractUITag {

    protected String imageURL;
    protected String imageCaption;
    protected String imageGroup;
    protected String thumbnailCssClass;
    protected Integer thumbnailHeight;
    protected Integer thumbnailWidth;
    protected String thumbnailDir;
    protected String thumbnailURI;

    
    private static Logger log = Logger.getLogger(LightBoxTag.class);
    
    public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
        return new LightBox(stack, req, res);
    }

    protected void populateParams() {        
        super.populateParams();
        final LightBox LightBox = (LightBox) component;
        LightBox.setImageURL(imageURL);
        LightBox.setImageCaption(imageCaption);
        LightBox.setImageGroup(imageGroup);
        LightBox.setThumbnailHeight(thumbnailHeight);
        LightBox.setThumbnailWidth(thumbnailWidth);
        LightBox.setThumbnailCssClass(thumbnailCssClass);
        LightBox.setThumbnailDir(thumbnailDir);
        LightBox.setThumbnailURI(thumbnailURI);
    }

    public void setImageURL(String imageURL) {
        this.imageURL = imageURL;
    }

    public void setImageCaption(String imageCaption) {
        this.imageCaption = imageCaption;
    }

    public void setImageGroup(String imageGroup) {
        this.imageGroup = imageGroup;
    }    

    public void setThumbnailHeight(Integer thumbnailHeight) {
        this.thumbnailHeight = thumbnailHeight;
    }

    public void setThumbnailWidth(Integer thumbnailWidth) {
        this.thumbnailWidth = thumbnailWidth;
    }

    public void setThumbnailCssClass(String thumbnailCssClass) {
        this.thumbnailCssClass = thumbnailCssClass;
    }

    public void setThumbnailDir(String thumbnailDir) {
        this.thumbnailDir = thumbnailDir;
    }

    public void setThumbnailURI(String thumbnailURI) {
        this.thumbnailURI = thumbnailURI;
    }
}
